package com.lk.org.service.impl;

import com.lk.basic.service.impl.BaseServiceImpl;
import com.lk.basic.util.PageList;
import com.lk.org.domain.Department;
import com.lk.org.mapper.DepartmentMapper;
import com.lk.org.query.DepartmentQuery;
import com.lk.org.service.IDepartmentService;
import org.apache.catalina.mapper.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class DepartmentServiceImpl extends BaseServiceImpl<Department> implements IDepartmentService {

    @Autowired
    private DepartmentMapper departmentMapper;

    @Override
    public void insert(Department department) {
        department.setCreate_time(new Date());
        super.insert(department);
    }

    @Override
    public void update(Department department) {
        department.setUpdate_time(new Date());
        super.update(department);
    }

    @Override
    public List<Department> getDepartmentTree() {
        return departmentMapper.loadAll();
    }

    @Override
    public void delAll(List<Long> para) {
        departmentMapper.delAll(para);

    }
    //    @Autowired
//    private DepartmentMapper departmentMapper;
//
//    @Override
//    @Transactional
//    public void insert(Department department) {
//        departmentMapper.insert(department);
//    }
//
//    @Override
//    @Transactional
//    public void delete(Serializable id) {
//        departmentMapper.delete(id);
//    }
//
//    @Override
//    @Transactional
//    public void update(Department department) {
//        departmentMapper.update(department);
//    }
//
//    @Override
//    public Department selById(Serializable id) {
//        return departmentMapper.selById(id);
//    }
//
//
//    @Override
//    public List<Department> selAll() {
//        return departmentMapper.selAll();
//    }
//
//    @Override
//    public PageList<Department> queryPage(DepartmentQuery query) {
//        Long total = departmentMapper.queryTotal(query);
//        if (total<0){
//            return new PageList<>();
//        }
//        List<Department> departments=departmentMapper.queryDatas(query);
//        return new PageList<>(total,departments);
//    }
}
